package cn.tgq007.arrays;

public class RemoveDuplicates0026 {

    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n == 0) {
            return 0;
        }
        int fast = 1, slow = 1;
        while (fast < n) {
            if (nums[fast] != nums[fast - 1]) {
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }

    public static void main(String[] args) {
        RemoveDuplicates0026 removeDuplicates0026 = new RemoveDuplicates0026();
        int[] nums = new int[] {1, 1, 2};
        int slow = removeDuplicates0026.removeDuplicates(nums);
        System.out.println(slow);
    }
}
